package com.zyzg.utils;

import com.alibaba.fastjson2.JSONObject;
import com.zyzg.utils.http.HttpUtils;

public class TDTGPSUtils {

    private static final String url = "http://api.tianditu.gov.cn/geocoder";

    private static final String token = "762cba2f57ef3be2dc8458c5a5d342ea";
//    private static final String token = "fae4cb0b542fc435a6a4fd719e4f8ff7";

    // 逆编译解析坐标位置
    public static JSONObject gpsDecompilation(Double lng, Double lat) {
        JSONObject p = new JSONObject();
        p.put("lon", lng);
        p.put("lat", lat);
        p.put("ver", 1);
        // 调用天地图API解析坐标位置
        return JSONObject.parseObject(HttpUtils.sendGet(url, "postStr=" + p.toJSONString() + "&type=geocode&tk="+token));
    }
}
